﻿using EnvDTE;
using SpecFlowTfsLinker.Entities;
using SpecFlowTfsLinker.Printer;
using SpecFlowTfsLinker.Tools;

namespace SpecFlowTfsLinker.VisualStudioHelper
{
    public class VisualStudioSpecFlowExtensionHelper
    {
        private readonly SpecFlowVsHelper _specFlowHelper;
        private readonly VisualStudioExtensionHelper _vsHelper;
        private readonly UserStory _us;

        public VisualStudioSpecFlowExtensionHelper(UserStory us, DTE visualStudioService)
        {
            _vsHelper = new VisualStudioExtensionHelper(visualStudioService);
            _specFlowHelper = new SpecFlowVsHelper(us);
            _us = us;
        }

        public void GenerateSpecFlow()
        {
            var visualStudioFolder = _vsHelper.CreateFolder(_specFlowHelper.FolderName);
            CreateSpecFlowFiles(visualStudioFolder);
        }

        private void CreateSpecFlowFiles(ProjectItem vsParentItem)
        {
            SpecFlowFileGenerator.GenererFichier(_specFlowHelper.FeatureFile, new FeaturePrinter(_us), vsParentItem);
            SpecFlowFileGenerator.GenererFichier(_specFlowHelper.StepDefinitionFile, new StepDefinitionPrinter(_us), vsParentItem);
        }
    }
}